Parse.Cloud.define('hello', function(req, res) {
  return 'Hi';
});

Parse.Cloud.define('averageScore', async (request) => {
  const query = new Parse.Query('GameScore');
  query.equalTo('playerName', request.params.playerName);
  const results = await query.find();
  let sum = 0;
  for (let i = 0; i < results.length; ++i) {
    sum += results[i].get('score');
  }
  return sum / results.length;
});